package org.ru.mse10.cvis.web.model.initializer;

/**
 * The Class DefaultInstanceInitializer.
 * 
 * @param <E>
 *            the element type
 */
public class DefaultInstanceInitializer<E> implements NewInstanceInitializer<E> {

	/** The clazz. */
	private Class<E> clazz;

	/**
	 * Instantiates a new default instance initializer.
	 * 
	 * @param clazz
	 *            the clazz
	 */
	public DefaultInstanceInitializer(Class<E> clazz) {
		this.clazz = clazz;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.ru.mse10.cvis.web.model.initializer.NewInstanceInitializer#newInstance
	 * ()
	 */
	@Override
	public E newInstance() {
		try {
			E newInstance = getInstanceClass().newInstance();
			return newInstance;
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.ru.mse10.cvis.web.model.initializer.NewInstanceInitializer#
	 * getInstanceClass()
	 */
	@Override
	public Class<E> getInstanceClass() {
		return clazz;
	}

}
